from pydantic import BaseModel, EmailStr, Field
from datetime import datetime
class UserBase(BaseModel):
    username: str
    email: EmailStr
    nickname: str



class UserRegister(UserBase):
    password: str

    class Config:
        orm_mode = True

class RoomBase(BaseModel):
    name: str
    description: str = Field(default="这是一个实时网络聊天室，欢迎您", max_length=255)
    is_public: bool = False

    class Config:
        orm_mode = True

class RoomCreate(RoomBase):
    password: str = None

    class config:
        orm_mode = True

class RoomResponse(RoomBase):
    create_at: datetime = Field(default_factory=datetime.now)
    create_id: int

    class Config:
        orm_mode = True